package com.satan.vote.controller;

import com.satan.vote.dto.VoteDetailDTO;
import com.satan.vote.entity.VoteDetail;
import com.satan.vote.entity.WxUserInfo;
import com.satan.vote.service.VoteDetailService;
import com.satan.vote.service.VoteItemService;
import com.satan.vote.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * @ClassName VoteDetailController
 * @Description TODO
 * @date 2023/8/14 19:35
 * @Version 1.0
 */
@RestController
@RequestMapping("/voteDetail")
public class VoteDetailController {
    @Autowired
    private VoteDetailService voteDetailService;
    @Autowired
    private VoteItemService voteItemService;

    @RequestMapping("/add")
    @Transactional
    public ResultVO add(@RequestBody VoteDetailDTO voteDetailDTO, @RequestHeader String
            token) {
        return voteDetailService.add(voteDetailDTO, token);
    }

    /**
     * 根据id查询投票人详情
     * @param voteId
     * @param voteItemId
     * @return
     */
    @GetMapping("/{voteId}/{voteItemId}")
    public ResultVO findById(@PathVariable(value = "voteId")Integer voteId,@PathVariable(value = "voteItemId")Integer voteItemId){
        return voteDetailService.findById(voteId,voteItemId);
    }

}
